#include "bernoullinode.h"

BernoulliNode::BernoulliNode(double val):
        Node(val)
{
    pNode = -1;
}

BernoulliNode::BernoulliNode(QString lbl, double val, double sd, Node * pNode, bool observed):
        Node(lbl, val, sd, observed)
{
    setPNode(pNode);
}

bool BernoulliNode::inRange(double v)
{
    return 0.0 <= v || v <= 1.0;
}

void BernoulliNode::setPNode(Node * node)
{
    pNode = addParentNode(node);
}

double BernoulliNode::computeLogLikelihood()
{    
    return VALID_LOG(gsl_ran_bernoulli_pdf(this->getValue(),
                                     parents->at(pNode)->getValue()));
}


